<?php if (empty($data) || count($data) == 0) { ?>
<div style="text-align:center; padding-top:20px;"><?php __('no result found'); ?></div>
<?php } else { ?>
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="reportTbl">
  <thead>
    <tr>
      <td>&nbsp;</td>
      <td><?php __('Malaysia'); ?></td>
      <td><?php __('Indonesia'); ?></td>
      <td><?php __('Monthly Total'); ?></td>
    </tr>
  </thead>
  <tbody>
<?php
          $i = $mTotal = $iTotal = 0;
          foreach ($data as $date=>$row) {
              $i    += 1;
              $rowTl = 0;
              $style = ($i%2==0)?'':' background-color:#E3E3E3;'; ?>
    <tr>
      <td align="right" valign="top" style="padding-top:8px;<?php e($style); ?>"><?php e($date); ?></td>
      <td valign="top">
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
<?php         $total = 0;
              foreach ($row['Malaysia'] as $stockist=>$amount) {
                  $total  += $amount;
                  $mTotal += $amount; ?>
          <tr style="background-color:transparent;">
            <td><?php e($stockist); ?></td>
            <td width="80" align="right" style="border-right:0;"><?php e(number_format($amount,2)); ?></td>
          </tr>
<?php         }
              $rowTl += $total;  ?>
          <tr style="background-color:transparent;">
            <td>&nbsp;</td>
            <td align="right" style="border-top:1px solid #000; border-right:0; color:#DD6F00;"><?php e(number_format($total,2)); ?></td>
          </tr>
        </table>
      </td>
      <td valign="top">
<?php         if (isset($row['Indonesia'])) { ?>
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
<?php             $total = 0;
                  foreach ($row['Indonesia'] as $stockist=>$amount) {
                      $total  += $amount;
                      $iTotal += $amount; ?>
          <tr style="background-color:transparent;">
            <td><?php e($stockist); ?></td>
            <td width="80" align="right" style="border-right:0;"><?php e(number_format($amount,2)); ?></td>
          </tr>
<?php             }
                  $rowTl += $total; ?>
          <tr style="background-color:transparent;">
            <td>&nbsp;</td>
            <td align="right" style="border-top:1px solid #000; border-right:0; color:#DD6F00;"><?php e(number_format($total,2)); ?></td>
          </tr>
        </table>
<?php         } ?>
      </td>
      <td align="right" valign="top" style="padding-top:8px; color:red;"><?php e(number_format($rowTl,2)); ?></td>
    </tr>
<?php     } ?>
  </tbody>
  <tfoot>
    <tr>
      <td align="right" style="font-weight:bold;"><?php __('Grand Total'); ?>: </td>
      <td align="right" class="total"><?php e(number_format($mTotal,2)); ?></td>
      <td align="right" class="total"><?php e(number_format($iTotal,2)); ?></td>
      <td align="right" class="total"><b><?php e(number_format($mTotal+$iTotal,2)); ?></b></td>
    </tr>
  </tfoot>
</table>
<?php } ?>